'use strict';
angular.module('app.services')
    .factory('HrService', function($http) {
        return {
            turnoverDepartSubmit: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/depart',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverDepartGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/turnover/depart/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverLeaderGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/turnover/leader/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverLeaderSubmit: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/leader',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverLeaderSummary: function(year, month) {
                return $http({
                    url: '/api/hr/turnover/leader/summary/' + year + '/' + month,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverInterviewGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/turnover/interview/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverInterviewSubmit: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/interview',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverInterviewSummaryType: function(sendBody) {
                if (sendBody.hotelId != null) {
                    var url = '/api/hr/turnover/interview/sum/type/' + sendBody.year + '/' + sendBody.month + '/' + sendBody.hotelId;
                    return $http({
                        url: url,
                        method: 'GET',
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                } else {
                    var url = '/api/hr/turnover/interview/sum/type';
                    return $http({
                        url: url,
                        method: 'POST',
                        data: angular.toJson(sendBody),
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                }
            },
            turnoverInterviewSummaryTop: function(sendBody) {
                if (sendBody.hotelId != null) {
                    var url = '/api/hr/turnover/interview/sum/top/' + sendBody.year + '/' + sendBody.month + '/' + sendBody.hotelId;
                    return $http({
                        url: url,
                        method: 'GET',
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                } else {
                    var url = '/api/hr/turnover/interview/sum/top';
                    return $http({
                        url: url,
                        method: 'POST',
                        data: angular.toJson(sendBody),
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                }

            },
            staffingTable1Get: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/staffing/table1/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            staffingTable1Post: function(sendBody) {
                return $http({
                    url: '/api/hr/staffing/table1',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            staffingTable2Get: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/staffing/table2/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            staffingTable2Post: function(sendBody) {
                return $http({
                    url: '/api/hr/staffing/table2',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruimentGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/recruiment/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruimentPost: function(sendBody) {
                return $http({
                    url: '/api/hr/recruiment',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recognitionGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/recognition/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recognitionPost: function(sendBody) {
                return $http({
                    url: '/api/hr/recognition',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            directoryGet: function(hotelId) {
                return $http({
                    url: '/api/hr/directory/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            directoryPost: function(sendBody) {
                return $http({
                    url: '/api/hr/directory',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            feedbackGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/feedback/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            feedbackPost: function(sendBody) {
                return $http({
                    url: '/api/hr/feedback',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recognitionReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/recognition/report',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            feedbackReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/feedback/report',
                    method: 'POST',
                    data: JSON.stringify(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruitReportGet: function(year, month, region, cluster, hotelId) {
                if (hotelId != null) {
                    var url = '/api/hr/recruiment/report/' + year + '/' + month + '/' + hotelId;
                    return $http({
                        url: url,
                        method: 'GET',
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                } else {
                    var url = '/api/hr/recruiment/report';
                    var sendBody = {
                        year: year,
                        month: month,
                        region: region,
                        cluster: cluster
                    }
                    return $http({
                        url: url,
                        method: 'POST',
                        data: angular.toJson(sendBody),
                        headers: {
                            'Content-Type': 'application/json;charset=utf-8'
                        }
                    })
                }
            },
            pathwayGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/hr/pathway/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            pathwayPost: function(sendBody) {
                return $http({
                    url: '/api/hr/pathway',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleGet: function(hotelId) {
                return $http({
                    url: '/api/hr/people/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peoplePost: function(sendBody) {
                return $http({
                    url: '/api/hr/people',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverDepartReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/depart/report/depart',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverPeriodReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/depart/report/period',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            turnoverBandReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/turnover/depart/report/band',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            staffingReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/staffing/table1/report',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            directoryReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/directory/report',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            pathwayReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/pathway/report',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/people/report',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleSingleUpdate: function(sendBody) {
                return $http({
                    url: '/api/hr/people/single',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleVReportGet: function(sendBody) {
                return $http({
                    url: '/api/hr/people/vreport',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleReportTopGet: function(sendBody) {
                return $http({
                    url: '/api/hr/people/vreporttop',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            peopleVacancyDetailGet: function(sendBody) {
                return $http({
                    url: '/api/hr/people/getbyregion',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            }
        }
    })
    .factory('TrService', function($http) {
        return {
            budgetGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/budget/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            budgetPost: function(sendBody) {
                return $http({
                    url: '/api/tr/budget',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            employeeGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/employee/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            employeePost: function(sendBody) {
                return $http({
                    url: '/api/tr/employee',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            managerGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/manager/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            managerPost: function(sendBody) {
                return $http({
                    url: '/api/tr/manager',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            externalGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/external/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            externalPost: function(sendBody) {
                return $http({
                    url: '/api/tr/external',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            crossGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/cross/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            crossPost: function(sendBody) {
                return $http({
                    url: '/api/tr/cross',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            otherGet: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/other/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            otherPost: function(sendBody) {
                return $http({
                    url: '/api/tr/other',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            depart1Get: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/depart1/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            depart1Post: function(sendBody) {
                return $http({
                    url: '/api/tr/depart1',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            depart2Get: function(year, month, hotelId) {
                return $http({
                    url: '/api/tr/depart2/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            depart2Post: function(sendBody) {
                return $http({
                    url: '/api/tr/depart2',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            summaryReport: function(sendBody) {
                return $http({
                    url: '/api/tr/sum/report',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            }

        }
    })
    .factory('PreopenService', function($http) {
        return {
            taskGet: function(hotelId) {
                return $http({
                    url: '/api/preopen/task/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            taskPost: function(sendBody) {
                return $http({
                    url: '/api/preopen/task',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            allTask: function() {
                return $http({
                    url: '/api/preopen/task/alltasks',
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruimentGet: function(hotelId) {
                return $http({
                    url: '/api/preopen/recruiment/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruimentPost: function(sendBody) {
                return $http({
                    url: '/api/preopen/recruiment',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            targetGet: function(hotelId) {
                return $http({
                    url: '/api/preopen/target/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            targetPost: function(sendBody) {
                return $http({
                    url: '/api/preopen/target',
                    method: 'POST',
                    data: angular.toJson(sendBody),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            completionSum: function() {
                return $http({
                    url: '/api/preopen/sum/completion',
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            ytdStaffNoSum: function() {
                return $http({
                    url: '/api/preopen/sum/ytd',
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            completionGet: function (hotelId) {
                return $http({
                    url: '/api/preopen/sum/comp/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            recruitGet: function () {
                return $http({
                    url: '/api/preopen/sum/recruit',
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            }
        }
    })
    .factory('HotelService', function($http) {
        return {
            all: function() {
                return $http({
                    url: '/api/hotels',
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                });
            },
            allByRegion: function(id) {
                return $http({
                    url: '/api/hotels/region/' + id,
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                });
            },
            allPreopen: function() {
                return $http({
                    url: '/api/hotels/preopen',
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                });
            },
            getRegions: function() {
                return $http({
                    url: '/api/common/getregions',
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                })
            },
            getClusters: function(regionId) {
                return $http({
                    url: '/api/common/getclusters/' + regionId,
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                })
            },
            getCurrentMonth: function() {
                return $http({
                    url: '/api/setting/current',
                    method: 'GET'
                })
            },
            saveCurrentMonth: function(year, month) {
                return $http({
                    url: '/api/setting/current/' + year + '/' + month,
                    hearders: 'Access-Control-Allow-Origin',
                    method: 'GET'
                })
            },
            getSettings: function() {
                return $http({
                    url: '/api/setting',
                    method: 'GET'
                })
            },
            saveSettings: function(body) {
                return $http({
                    url: '/api/setting',
                    method: 'POST',
                    data: angular.toJson(body),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            getProgress: function(year, month, hotelId) {
                return $http({
                    url: '/api/progress/' + year + '/' + month + '/' + hotelId,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            getProgressSummary: function(year, month) {
                return $http({
                    url: '/api/progress/sum/' + year + '/' + month,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            getProgressSummaryAll: function(year, month) {
                return $http({
                    url: '/api/progress/sum/all/' + year + '/' + month,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            deleteHotel: function(id) {
                return $http({
                    url: '/api/hotels/' + id,
                    method: 'DELETE',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            get: function(id) {
                return $http({
                    url: '/api/hotels/' + id,
                    method: 'GET',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            saveHotel: function(body) {
                return $http({
                    url: '/api/hotels',
                    method: 'POST',
                    data: angular.toJson(body),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })

            }
        }
    })
    .factory('UserService', function($http) {
        return {
            logout: function() {
                return $http({
                    url: '/api/user/logout',
                    method: 'GET'
                })
            },
            getHotelName: function(code) {
                return $http({
                    url: '/api/common/gethotelname/' + code,
                    method: 'GET'
                })
            },
            getAllAdminUsers: function() {
                return $http({
                    url: '/api/user',
                    method: 'GET'
                });
            },
            forgetPwd: function(code) {
                return $http({
                    url: '/api/user/modify/' + code,
                    method: 'GET'
                })
            },

            createNewAdmin: function(user) {
                return $http({
                    url: '/api/user',
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                });
            },

            saveAdmin: function(user) {
                return $http({
                    url: '/api/user',
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                });
            },

            deleteAdminUser: function(id) {
                return $http({
                    url: '/api/user/' + id,
                    method: 'DELETE',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                });
            },
            login: function(user) {
                return $http({
                    url: '/api/user/login',
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                });
            },
            get: function(id, role) {
                if (role == 'admin' || role == 'revenuer') {
                    return $http({
                        url: '/api/user/' + id,
                        method: 'GET'
                    });
                } else {
                    return $http({
                        url: '/api/' + role + '/' + id,
                        method: 'GET'
                    });
                }
            },
            update: function(role, user) {
                return $http({
                    url: '/api/' + role,
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                });
            },
            submitProfile: function(role, user) {
                return $http({
                    url: '/api/' + role + '/approval',
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            verifyUser: function(role, userId, type) {
                return $http({
                    url: '/api/' + role + '/' + type + '/' + userId,
                    method: 'GET'
                })
            },
            getAlreadyUsers: function(role, currentPage) {
                return $http({
                    url: '/api/' + role + '/approved?page.size=15&page.page=' + currentPage + '&page.sort=id&page.sort.dir=desc',
                    method: 'GET'
                })
            },
            getWaitUsers: function(role, currentPage) {
                return $http({
                    url: '/api/' + role + '/approving?page.size=15&page.page=' + currentPage + '&page.sort=id&page.sort.dir=desc',
                    method: 'GET'
                })
            },
            getNewUsers: function(role, currentPage) {
                return $http({
                    url: '/api/' + role + '/pending?page.size=15&page.page=' + currentPage + '&page.sort=id&page.sort.dir=desc',
                    method: 'GET'
                })
            },
            changePwd: function(user) {
                return $http({
                    url: '/api/user/password',
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            changeEPwd: function(token, user) {
                return $http({
                    url: '/api/user/password/' + token,
                    method: 'POST',
                    data: JSON.stringify(user),
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8'
                    }
                })
            },
            isLoggedin: function() {
                return $http({
                    url: '/api/isloggedin',
                    method: 'GET'
                });
            }
        }
    })
